/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package utilidades;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.postgresql.ds.PGPoolingDataSource;


/**
 *
 * @author Miguel
 */
public class ConexionBaseDtos {
    private static ConexionBaseDtos Conec=null;
    private static PGPoolingDataSource datos=null;
    static 
    {
        Conec= new ConexionBaseDtos();
    }
    private ConexionBaseDtos()
    {
        datos=new PGPoolingDataSource();
        datos.setDataSourceName("Pollo");
        datos.setServerName("localhost");
        datos.setPortNumber(5432);
        datos.setUser("postgres");
        datos.setPassword("123456789");
        datos.setDatabaseName("postgres");
        datos.setMaxConnections(10);

    }
    public static Connection ObternerConexion()
    {
        try{
            return datos.getConnection();
        }
        catch(SQLException e)
        {
            System.out.printf(null,e);
        }
        return null;
    }
    public static void CerrarConeccion(Connection c)
    {
        try {
            c.close();
        } catch (SQLException ex) {
            Logger.getLogger(ConexionBaseDtos.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
